class Faq < ActiveRecord::Base
  has_many :faq_relations
  has_many :articles, :through => :faq_relations
  
  def self.search(question,limit=10)
    Faq.find_by_sql("SELECT faqs.* FROM faqs WHERE faqs.question LIKE '%#{question}%' LIMIT #{limit}")
  end
  
  def add_subscriber(email)
    FaqSubscribers.create(:email => email, :faq_id => id)
  end
end
